﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;

namespace QuanLyKhoThucPham
{
    public partial class FrmDangNhap : Form
    {
        public FrmDangNhap()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            lbGio.Text = System.DateTime.Now.Hour.ToString();
            lbPhut.Text = System.DateTime.Now.Second.ToString();
            lbGiay.Text = System.DateTime.Now.Minute.ToString();
            tmr.Enabled = true;

        }

        private void tmr_Tick(object sender, EventArgs e)
        {
            lbGio.Text = System.DateTime.Now.Hour.ToString();
            lbPhut.Text = System.DateTime.Now.Second.ToString();
            lbGiay.Text = System.DateTime.Now.Minute.ToString();
            ng.Text = System.DateTime.Now.Day.ToString();
            th.Text = System.DateTime.Now.Month.ToString();
            nm.Text = System.DateTime.Now.Year.ToString();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (txtTenDangNhap.Text == "" || txtMatKhau.Text == "")
            {
                MessageBox.Show("Hãy nhập đủ dữ liệu");
            }
            else
            {
                busNhanVien NhanVienBUS = new busNhanVien();
                dtoNhanVien NhanVienDTO = new dtoNhanVien();
                NhanVienDTO.TenTaiKhoan = txtTenDangNhap.Text;
                NhanVienDTO.MatKhau = txtMatKhau.Text;
                int kq = NhanVienBUS.KiemTraDangNhap(NhanVienDTO);
                switch (kq)
                {
                    case 0:
                        MessageBox.Show("Sai mật khẩu");
                        break;
                    case 1:
                        MessageBox.Show("Xin chào Admin");
                                                break;
                    case 2:
                        MessageBox.Show("Xin Chào " + txtTenDangNhap.Text);
                        break;

                }
            }

        }
    }
}
